﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InPutMaterialManage
{
    private List<Vector3> gOrginMaterialPositionList;
    private List<GameObject> gOriginMaterailList;
    private GameObject gOriginMaterial;

    public InPutMaterialManage(GameObject iOrignMaterail)
    {
        gOriginMaterial = iOrignMaterail;
        InitPositionList();
    }

    public GameObject GetOriginMaterial()
    {
        if (gOriginMaterailList.Count != 0)
        { 
            GameObject pOrginMaterial = gOriginMaterailList[0];
            gOriginMaterailList.RemoveAt(0);
            return pOrginMaterial;
        }
        else
        {
            InitPositionList();
            GameObject pOrginMaterial = gOriginMaterailList[0];
            gOriginMaterailList.RemoveAt(0);
            return pOrginMaterial;
        }
    }


    private void InitPositionList()
    {
        gOrginMaterialPositionList = new List<Vector3>();
        gOriginMaterailList = new List<GameObject>();

        int pX = -350, pY = 35, pZ = -200;
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                pX = -350 - 20 * i;
                pZ = -200 - 20 * j;

                GameObject pOrignMaterail = GameObject.Instantiate(gOriginMaterial);
                pOrignMaterail.transform.position = new Vector3(pX, pY, pZ);
                gOriginMaterailList.Add(pOrignMaterail);
            }
        }

    }

}
